package com.COMP3111H.project;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.text.Html;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class Help extends Activity {
	TextView para1, para2, para3;
	Button rtnPrev;
	final int HELP = 0;
	Button menu;
	
	String paraHtml1 = "We are still in Beta (as always), and bugs are "
			+ "something Bookworm ould really love. thoug"
			+ "our name is BookWarm (Instead of Bookworm), "
			+ "we are actively looking for bugs in our apps!"
			+ "<br /><br />"
			+ "Please Do Report Website Problems or Bugs to xxx "
			+ "to help us improve the website. Please include "
			+ "some screeshots or description for the problems, "
			+ "And your feed back is much appreciated."
			+ "<b>BookWarm credits and coupons would be awarded to timely reports.</b>"
			+ "Thanks!!!";

	String paraHtml2 = "Cncellation and questions regarding the books, "
			+ "please email <b>book@bookwarm.org</b>. " + "Thanks so much!";

	String paraHtml3 = "Please redirect general inquiry to "
			+ "<b>info@bookwarm.org</b>. Thanks!";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.help);

		(para1 = (TextView) findViewById(R.id.tvHelpPara1)).setText(Html
				.fromHtml(paraHtml1));

		(para2 = (TextView) findViewById(R.id.tvHelpPara2)).setText(Html
				.fromHtml(paraHtml2));

		(para3 = (TextView) findViewById(R.id.tvHelpPara3)).setText(Html
				.fromHtml(paraHtml3));
		
		(rtnPrev = (Button) findViewById(R.id.b_Help_Return))
		.setOnClickListener(new View.OnClickListener() {
				public void onClick(View v) {
				// TODO Auto-generated method stub
				finish();	
				}
		});
		
		
		menu = (Button) findViewById(R.id.help_menu);
	}
	
	@Override
    protected void onResume() {
		super.onResume();
		if (LoginUtility.checkLoginStatus(this)) {
			menu.setOnClickListener(new View.OnClickListener() {
				public void onClick(View v) {
					 String[] choices={"Home","View My Profile","Cancel"};  
					             AlertDialog dialog = new AlertDialog.Builder(Help.this)  
					                     // .setIcon(android.R.drawable.btn_star)  
					                      .setTitle("Menu")  
					                      .setItems(choices, onselect_logged).create();  
					             dialog.show();  
				}
			});
		}
		else{
			menu.setOnClickListener(new View.OnClickListener() {
				public void onClick(View v) {
					 String[] choices={"Home","Cancel"};  
					             AlertDialog dialog = new AlertDialog.Builder(Help.this)  
					                     // .setIcon(android.R.drawable.btn_star)  
					                      .setTitle("Menu")  
					                      .setItems(choices, onselect_not_logged).create();  
					             dialog.show();  
				}
			});
		}
	}
	
	OnClickListener onselect_logged = new OnClickListener() {
		public void onClick(DialogInterface dialog, int which) {
			// TODO Auto-generated method stub
			Intent myIntent;
			switch (which) {
			case 0:
				myIntent = new Intent(Help.this, Home.class);
				startActivity(myIntent);
				break;
			case 1:
				myIntent = new Intent(Help.this, My_Profile.class);
				startActivity(myIntent);
				break;
			case 2:
				dialog.dismiss();
				break;
			}
		}
	};
	
	OnClickListener onselect_not_logged = new OnClickListener() {
		public void onClick(DialogInterface dialog, int which) {
			// TODO Auto-generated method stub
			Intent myIntent;
			switch (which) {
			case 0:
				myIntent = new Intent(Help.this, Home.class);
				startActivity(myIntent);
				break;
			case 1:
				dialog.dismiss();
				break;
			}
		}
	};
}
